﻿using IterationLife.ContentResources.Models;
using Util.Datas.Ef;

namespace IterationLife.Datas.Mappings.ContentResources {
    /// <summary>
    /// 内容资源图集映射配置
    /// </summary>
    public class ContentResourcePictureMap : EntityMapBase<ContentResourcePicture> {
        /// <summary>
        /// 映射表
        /// </summary>
        protected override void MapTable() {
            ToTable( "ContentResourcePictures", "Commons" );
        }
        
        /// <summary>
        /// 映射属性
        /// </summary>
        protected override void MapProperties() {
            //内容资源图集编号
            Property(t => t.Id)
                .HasColumnName("ContentResourcePictureId");
            //图片面图
            Property(t => t.PictureJsonStr)
                .HasColumnName("Picture");
        }
        
        /// <summary>
        /// 映射导航属性
        /// </summary>
        protected override void MapAssociations() {
            //内容资源
            HasOptional(t => t.ContentResource)
                .WithMany(t => t.ContentResourcePictures)
                .HasForeignKey(d => d.ContentResourceId);
        }
    }
}